package com.gbei.center.oauth.controller.aopController;

import com.gbei.center.base.BaseController;
import com.gbei.center.config.restauth.RestAuthConfig;
import com.gbei.center.oauth.req.*;
import com.gbei.center.oauth.service.WaterMachineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 水机接口
 *
 * @author
 * @version
 */
@RestController
@RequestMapping("waterMachine")
@Api(description = "水机接口")
@RestAuthConfig(release = true) //全局放行
public class WaterMachineController extends BaseController {

  private static Logger log = LoggerFactory.getLogger(WaterMachineController.class);

  @Autowired
  private WaterMachineService waterMachineService;
  

  @PostMapping("addOperator")
  @ApiOperation(value = "设置区县运营商", notes = "同一区县可添加多个运营商")
  public String addOperator(@Valid ReqAddOperator req, BindingResult br){
    checkParams(br);
    log.info("水机设置区县运营商请求：{}", req);
    String apiUrl = "waterMachine/addOperator";
    return waterMachineService.addOperator(req,apiUrl);
  }


  @PostMapping("deleteOperator")
  @ApiOperation(value = "删除区县运营商")
  public String deleteOperator(@Valid ReqDeleteOperator req, BindingResult br){
    checkParams(br);
    log.info("水机删除区县运营商请求：{}", req);
    String apiUrl = "waterMachine/deleteOperator";
    return waterMachineService.deleteOperator(req,apiUrl);
  }

  @PostMapping("addMerchant")
  @ApiOperation(value = "添加区县商户")
  public String addMerchant(@Valid ReqAddMerchant req, BindingResult br){
    checkParams(br);
    log.info("水机添加区县商户请求：{}", req);
    String apiUrl = "waterMachine/addMerchant";
    return waterMachineService.addMerchant(req,apiUrl);
  }


  @PostMapping("deleteMerchant")
  @ApiOperation(value = "删除区县商户")
  public String deleteMerchant(@Valid ReqDeleteMerchant req, BindingResult br){
    checkParams(br);
    log.info("水机删除区县商户请求：{}", req);
    String apiUrl = "waterMachine/deleteMerchant";
    return waterMachineService.deleteMerchant(req,apiUrl);
  }

  @PostMapping("placeOrder")
  @ApiOperation(value = "下单")
  public String placeOrder(@Valid ReqPlaceOrder req, BindingResult br){
    checkParams(br);
    log.info("水机下单请求：{}", req);
    String apiUrl = "waterMachine/placeOrder";
    return waterMachineService.placeOrder(req,apiUrl);
  }

}
